package com.example.oracle.helper;

import lombok.AccessLevel;
import lombok.Data;
import lombok.experimental.FieldDefaults;


@Data
@FieldDefaults(level=AccessLevel.PRIVATE)
public class HttpResult {

	Integer code;
	
	String msg;
	
	Object data;
	
	private final static HttpResult SUCCESS = new HttpResult(200, "操作成功");

	public static HttpResult success(){
		return HttpResult.SUCCESS;
	}

	public static HttpResult params_error(){
		return new HttpResult(405, "参数列表校验未通过，请求被中断");
	}

	public static HttpResult validity_eror(){
		return new HttpResult(406, "参数有效性校验未通过，请求被中断");
	}

	public static HttpResult no_permission(){
		return new HttpResult(403, "操作失败，权限校验未通过，请求被拒绝");
	}

	public static HttpResult system_error(){
		return new HttpResult(500, "服务器发生异常，请稍后重试");
	}

	public static HttpResult fallback(){
		return new HttpResult(501, "哎呀，服务器开小差去了");
	}
	
	public HttpResult() {
		super();
		this.code = 200;
	}

	public HttpResult(Object data) {
		super();
		this.code = 200;
		this.data = data;
	}

	public HttpResult(Integer code, String msg) {
		super();
		this.code = code;
		this.msg = msg;
	}

	public HttpResult(Integer code, Object data) {
		super();
		this.code = code;
		this.data = data;
	}
}
